package com.iyundao.io.mapper;

import com.iyundao.io.model.SysRole;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface SysRoleMapper {
    @Delete({
        "delete from sys_role",
        "where sid = #{sid,jdbcType=CHAR}"
    })
    int deleteByPrimaryKey(String sid);

    @Insert({
        "insert into sys_role (sid, real_name, ",
        "show_name, parent_id, ",
        "flag, create_date, ",
        "create_id, orde_by)",
        "values (#{sid,jdbcType=CHAR}, #{realName,jdbcType=VARCHAR}, ",
        "#{showName,jdbcType=VARCHAR}, #{parentId,jdbcType=CHAR}, ",
        "#{flag,jdbcType=VARCHAR}, #{createDate,jdbcType=TIMESTAMP}, ",
        "#{createId,jdbcType=CHAR}, #{ordeBy,jdbcType=TINYINT})"
    })
    int insert(SysRole record);

    @InsertProvider(type=SysRoleSqlProvider.class, method="insertSelective")
    int insertSelective(SysRole record);

    @Select({
        "select",
        "sid, real_name, show_name, parent_id, flag, create_date, create_id, orde_by",
        "from sys_role",
        "where sid = #{sid,jdbcType=CHAR}"
    })
    @Results({
        @Result(column="sid", property="sid", jdbcType=JdbcType.CHAR, id=true),
        @Result(column="real_name", property="realName", jdbcType=JdbcType.VARCHAR),
        @Result(column="show_name", property="showName", jdbcType=JdbcType.VARCHAR),
        @Result(column="parent_id", property="parentId", jdbcType=JdbcType.CHAR),
        @Result(column="flag", property="flag", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_date", property="createDate", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="create_id", property="createId", jdbcType=JdbcType.CHAR),
        @Result(column="orde_by", property="ordeBy", jdbcType=JdbcType.TINYINT)
    })
    SysRole selectByPrimaryKey(String sid);

    @UpdateProvider(type=SysRoleSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(SysRole record);

    @Update({
        "update sys_role",
        "set real_name = #{realName,jdbcType=VARCHAR},",
          "show_name = #{showName,jdbcType=VARCHAR},",
          "parent_id = #{parentId,jdbcType=CHAR},",
          "flag = #{flag,jdbcType=VARCHAR},",
          "create_date = #{createDate,jdbcType=TIMESTAMP},",
          "create_id = #{createId,jdbcType=CHAR},",
          "orde_by = #{ordeBy,jdbcType=TINYINT}",
        "where sid = #{sid,jdbcType=CHAR}"
    })
    int updateByPrimaryKey(SysRole record);
}